home *** CD-ROM | disk | FTP | other *** search
- /* strdup.c From TC Bible page 281 Use strdup to allocate
- memory and copy a given string into that space */
-
- #include <stdio.h>
- #include <string.h>
- main()
- {
- char str1[80], *str1_copy;
- printf("Enter a string: ");
- gets(str1);
- str1_copy = strdup(str1);
- printf("String duplicated. Result is: %s\n", str1_copy);
-
- }